﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;

namespace GabageFactory.Models
{
    public class TailingpondFilldamReposity : Reposity
    {
        public tailingpond_daily_filldam_info GetDailyFilldamInfo(int tailingpondId, DateTime date)
        {
            var filldam = from s in _dataContext.tailingpond_daily_filldam_infos
                             where tailingpondId == s.tailingpond_id && s.date == date.Date
                             select s;

            if (filldam != null && filldam.Count() > 0)
            {
                return filldam.First();
            }
            else
            {
                return null;
            }
        }

        public tailingpond_daily_filldam_info CreateFilldamInfo(tailingpond_daily_filldam_info filldam)
        {
            _dataContext.tailingpond_daily_filldam_infos.InsertOnSubmit(filldam);
            SubmitChanges();
            return filldam;
        }

        public bool DeleteFilldamInfo(tailingpond_daily_filldam_info filldam)
        {
            _dataContext.tailingpond_daily_filldam_infos.DeleteOnSubmit(filldam);
            return true;
        }
    }
}